<%@ page language="java" pageEncoding="UTF-8"%>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>BSMS</title>
<%@ include file="../common/taglibs.jsp"%>
<%@ include file="../common/meta.jsp"%>
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/easyui/themes/myself/easyui.css" />
<link rel="stylesheet" type="text/css"
	href="<%=request.getContextPath()%>/easyui/themes/icon.css" />
<script type="text/javascript"
	src="<%=request.getContextPath()%>/resources/js/WdatePicker.js"></script>
<script type="text/javascript"
	src='<%=request.getContextPath()%>/dwr/engine.js'></script>
<script type="text/javascript"
	src='<%=request.getContextPath()%>/dwr/util.js'></script>
<script type="text/javascript"
	src='<%=request.getContextPath()%>/dwr/interface/baseVerifyService.js'></script>
<script type="text/javascript">
	function saveStaff() {
		var staffNo = document.getElementById("staffNo");
		if (trim(staffNo.value) == "") {
			alert("请输入员工账号！");
			staffNo.focus();
			return false;
		}
		var reg = /^[a-zA-Z]+\w*$/;
		if (!reg.test(staffNo.value)) {
			alert("账号只能由数字、字母和下划线组成，并且只能以字母开头！");
			staffNo.focus();
			return false;
		}
		var staffName = document.getElementById("staffName");
		if (trim(staffName.value) == "") {
			alert("请输入员工姓名！");
			staffName.focus();
			return false;
		}
		var deptName = document.getElementById("deptName");
		if (trim(deptName.value) == "") {
			alert("请选择员工所属部门！");
			deptName.focus();
			return false;
		}

		var email = document.getElementById("email");
		if (trim(email.value) == "") {
			alert("请输入员工电子邮件！");
			email.focus();
			return false;
		}

		if ("insert" == "${operate}") {
			baseVerifyService.isStaffNoUsed(staffNo.value, showVerify);
		} else {
			showVerify(false);
		}
	}
	function showVerify(data) {
		if (data == true) {
			alert("此员工账号已被占用，请重新输入！");
			document.getElementById("staffNo").focus();
			return false;
		} else {
			document.getElementById("ctBaseForm").submit();
		}
	}
	function selectOrg() {
		var sURL = "selectDept.action";
		//var sFeatures = "dialogWidth=400px;dialogHeight=500px;status:no";
		var obj = window.open(sURL,'newwindow','height=500,width=400,top=100,left=300,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no');
		/* if (obj != null && obj != undefined) {
			document.getElementById("deptId").value = obj.deptId;
			document.getElementById("deptName").value = obj.deptName;
		} */
	}
	function selectRole() {
		var sURL = "roleSelect.action";
		var sFeatures = "dialogWidth=400px;dialogHeight=500px;status:no";
		var obj = window.showModalDialog(sURL, null, sFeatures);
		if (obj != null && obj != undefined) {
			document.getElementById("roleId").value = obj.roleId;
			document.getElementById("roleName").value = obj.roleName;
		}
	}
	function resetPassword() {
		document.getElementById("ctBaseForm").action = "resetPassword.action";
		document.getElementById("ctBaseForm").submit();
	}

	<s:if test='#request.operate == "reset_success"'>
		alert("密码重置成为您的登录名！");		
	</s:if>
</script>
</head>
<body class="easyui-layout">
	<form id="ctBaseForm" action="staffSave.action" method="post">
		<input type="hidden" name="operate" value="${operate}" />
		<table border="0" align="center" cellpadding="3" cellspacing="1">
			<tr>
				<td>账号<font color="#FF0000">*</font></td>
				<td><input type="text" id="staffNo" name="staff.staffNo"
					value="${staff.staffNo}"
					<s:if test='#request.operate == "update"'>readonly</s:if> /></td>
				<td>所属部门<font color="#FF0000">*</font></td>
				<td><input type="hidden" id="deptId" name="staff.deptId"
					value="${staff.deptId}" /> <input type="text" id="deptName"
					value="${staff.deptName}" 
					onclick="selectOrg()" readonly="readonly" /> &nbsp;<img
					src="<%=request.getContextPath()%>/resources/img/search.gif"
					width="16" height="16" style="cursor: hand" />&nbsp;</td>
			</tr>
			<tr>
				<td nowrap="nowrap">姓名<font color="#FF0000">*</font></td>
				<td><input type="text" id="staffName" name="staff.staffName"
					value="${staff.staffName}" /></td>
				<td>性别</td>
				<td></td>
			</tr>
			<tr>
				<td>入职日期</td>
				<td><input type="text" id="employDate" name="staff.employDate"
					value="<s:date name='staff.employDate' format='yyyy-MM-dd'/>"
					onclick="WdatePicker({el:'employDate'})" />
					&nbsp;<img
					src="<%=request.getContextPath()%>/images/calendar.gif"
					width="16" height="16" /></td>
				<td>职位</td>
				<td><input type="text" name="staff.position"
					value="${staff.position}" /></td>
			</tr>
			<tr>
				<td>联系电话</td>
				<td><input type="text" name="staff.telephone"
					value="${staff.telephone}" /></td>
				<td >手机</td>
				<td><input type="text" name="staff.mobile"
					value="${staff.mobile}" /></td>
			</tr>
			<tr>
				<td>QQ</td>
				<td><input type="text" name="staff.qq" value="${staff.qq}"
					 /></td>
				<td>电子邮件<font color="#FF0000">*</font></td>
				<td><input type="text" id="email" name="staff.email"
					value="${staff.email}" /></td>
			</tr>
			<tr>
				<td>联系地址</td>
				<td><input type="text" name="staff.address"
					value="${staff.address}" /></td>
				<td>备注</td>
				<td><input type="text" name="staff.memo" value="${staff.memo}"
					/></td>
			</tr>
			<tr>
				<td>所属角色</td>
				<td colspan="3"><input type="hidden" id="roleId"
					name="staff.roleId" value="${staff.roleId}" /> <input type="text"
					id="roleName" value="${staff.roleName}" style="WIDTH: 43%"
					onclick="selectRole()" readonly="readonly" /> &nbsp;<img
					src="<%=request.getContextPath()%>/resources/img/search.gif"
					width="16" height="16" style="cursor: hand" />&nbsp;</td>
			</tr>
		</table>
		<br />
		<table border="0" align="center" cellpadding="0" cellspacing="0">
			<tr>
				<td align="center">
				<div id="dlg-buttons">
						<s:if test="%{operate != 'insert'}">
							<a href="#" onclick="resetPassword()" class="easyui-linkbutton">重置密码</a>
						</s:if>
						<a href="#" onclick="saveStaff();" class="easyui-linkbutton">保存</a>
						<a href="#" onclick="parent.$('#dlg').dialog('close');"
							class="easyui-linkbutton">取消</a>
					</div>
				</td>
			</tr>
		</table>
		
	</form>
</body>
</html>